import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AmazonListingVO, AmazonListingForm, AmazonListingQuery } from '@/api/lingxing/amazonListing/types';

/**
 * 查询亚马逊链接列表
 * @param query
 * @returns {*}
 */

export const listAmazonListing = (query?: AmazonListingQuery): AxiosPromise<AmazonListingVO[]> => {
  return request({
    url: '/lingxing/amazonListing/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询亚马逊链接详细
 * @param id
 */
export const getAmazonListing = (id: string | number): AxiosPromise<AmazonListingVO> => {
  return request({
    url: '/lingxing/amazonListing/' + id,
    method: 'get'
  });
};

/**
 * 新增亚马逊链接
 * @param data
 */
export const addAmazonListing = (data: AmazonListingForm) => {
  return request({
    url: '/lingxing/amazonListing',
    method: 'post',
    data: data
  });
};

/**
 * 修改亚马逊链接
 * @param data
 */
export const updateAmazonListing = (data: AmazonListingForm) => {
  return request({
    url: '/lingxing/amazonListing',
    method: 'put',
    data: data
  });
};

/**
 * 删除亚马逊链接
 * @param id
 */
export const delAmazonListing = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/amazonListing/' + id,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const syncData = () => {
  return request({
    url: '/lingxing/amazonListing/syncData',
    method: 'post'
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/amazonListing/getNewestUpdateTime',
    method: 'get'
  });
};
